import 'package:flutter/material.dart';
import 'package:meal/components/market/data_analysis.dart';
import 'package:meal/components/market/use_record.dart';
import 'package:meal/constant/sizes.dart';
import 'package:meal/utils/tools.dart';

class FullInfo extends StatefulWidget {
  const FullInfo({Key? key}) : super(key: key);

  @override
  State<FullInfo> createState() => _FullInfoState();
}

class _FullInfoState extends State<FullInfo> with SingleTickerProviderStateMixin {

  late TabController _controller;

  List<String> tabs = ['使用记录', '数据分析'];

  PreferredSizeWidget get bottom {
    return PreferredSize(
        preferredSize: const Size.fromHeight(Sizes.default50),
        child: Container(
          decoration: const BoxDecoration(
            color: Colors.white,
          ),
          height: Sizes.default50,
          alignment: Alignment.center,
          child: ToolsUtils.getClientTabBar(tabs, _controller),
        ));
  }

  @override
  void initState() {
    _controller = TabController(length: tabs.length, vsync: this);
    super.initState();
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: ToolsUtils.getDefaultBackgroundColor(),
      appBar: ToolsUtils.getDefaultBrnAppBar('满赠使用详情', bottom: bottom),
      body: TabBarView(
        controller: _controller,
        children: const [
          MarketUseRecord(),
          MarketDataAnalysis()
        ],
      ),
    );
  }
}
